package com.atguigu.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*1.实例化   构造器
2.初始化      init
3.接受请求，处理请求，服务  service
4.销毁  Destroy
* */

/*servlet在tomcat中是单例的
servlet的成员变量在多个线程之中是共享的
不建议在servlet方法中改变成员变量
* */
/*@WebServlet("/servletLifecycle")*/
@WebServlet(value = "servletLifecycle",loadOnStartup = 6)
public class servletlifecycle extends HttpServlet {

    public servletlifecycle(){
        System.out.println("构造器");
    }
    @Override
    public void init() throws ServletException {
        System.out.println("初始化");
    }
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("服务");
    }
    @Override
    public void destroy() {
        System.out.println("销毁");
    }
}
